package edu.hawaii.wattwaiter.page;

import java.util.ArrayList;
import org.apache.wicket.extensions.markup.html.tabs.ITab;
import org.apache.wicket.markup.html.CSSPackageResource;
import org.apache.wicket.markup.html.JavascriptPackageResource;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import edu.hawaii.wattwaiter.page.gridinfo.GridInfo;
import edu.hawaii.wattwaiter.page.homepage.HomePage;
import edu.hawaii.wattwaiter.page.stoplight.StopLight;

/**
 * Template Page for WattWaiter.
 * 
 * @author Remy Baumgarten
 * 
 */
public class BasePage extends WebPage {

  /** Support serialization. */
  private static final long serialVersionUID = 1L;
  /** Page Title. **/
  private String pageTitle = "(no title)";
  /** Date Format. **/
  public static final String DATA_FORMAT = "yyyy-MM-dd";

  // Screen variable to stop PMD's warnings
  private String screen = "screen";

  /**
   * Constructor to create the base page.
   * 
   */
  public BasePage() {
    // Add CSS to head
    add(CSSPackageResource.getHeaderContribution(edu.hawaii.wattwaiter.page.BasePage.class,
        "style/styles.css", screen));
    add(CSSPackageResource.getHeaderContribution(edu.hawaii.wattwaiter.page.BasePage.class,
        "style/tabs.css", "screen"));
    add(JavascriptPackageResource.getHeaderContribution(edu.hawaii.wattwaiter.page.BasePage.class,
        "style/jquery-1.3.2.min.js"));

    // Add Title to Title Property
    add(new Label("title", "WattWaiter - Seeing Energy"));

    final ArrayList<ITab> tabs = new ArrayList<ITab>();

    tabs.add(new MyTabs("Home") {
      private static final long serialVersionUID = 1L;

      @Override
      public Panel createPanel() {
        return new HomePage();
      }
    });

    tabs.add(new MyTabs("Stop Light") {
      private static final long serialVersionUID = 1L;

      @Override
      public Panel createPanel() {
        return new StopLight();
      }
    });

    tabs.add(new MyTabs("Grid Info") {
      private static final long serialVersionUID = 1L;

      @Override
      public Panel createPanel() {
        return new GridInfo();
      }
    });

    final MyTabbedPanel tabpanel = new MyTabbedPanel("tabpanel", tabs);
    add(tabpanel);

  }

  /**
   * Getter for Title.
   * 
   * @return the page title
   */
  public final String getPageTitle() {
    return pageTitle;
  }

  /**
   * Setter for Title.
   * 
   * @param title of page
   */
  public final void setPageTitle(String title) {
    pageTitle = title;
  }

  /**
   * Getter for the Session.
   * 
   * @return the session for this page
   */
  public WattWaiterSession getWattWaiterSession() {
    return (WattWaiterSession) getSession();
  }
}
